package com.yupi.yupicturebackend.common;

import com.yupi.yupicturebackend.exception.ErrorCode;
import lombok.Data;

import java.io.Serializable;

@Data
public class BaseResponse<T> implements Serializable {

    private int code;
    private String message;
    private T data;

    /**
     * @param code 状态码
     * @param message 错误信息
     * @param data 返回数据
     */
    public BaseResponse(int code, String message, T data)
    {
        this.code = code;
        this.message = message;
        this.data = data;
    }

    /**
     * @param code 状态码
     * @param message 错误信息
     */
    public BaseResponse(int code, String message)
    {
        this(code, message, null);
    }

    /**
     * @param errorCode 错误码
     */
    public BaseResponse(ErrorCode errorCode)
    {
        this(errorCode.getCode(), errorCode.getMessage(), null);
    }
}
